<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <!-- <el-form-item label="公司名称" prop="factoryName">
         <el-input
           v-model="queryParams.factoryName"
           placeholder="请输入公司名称"
           clearable
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
       <el-form-item label="公司代码" prop="factoryCode">
         <el-input
           v-model="queryParams.factoryCode"
           placeholder="请输入公司代码"
           clearable
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>-->
      <el-form-item label="出库单号" prop="danhao">
        <el-input
          v-model="queryParams.danhao"
          placeholder="请输入出库单号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="出库类型" prop="chukuType">
        <el-select v-model="queryParams.chukuType" placeholder="请选择出库类型" clearable>
          <el-option
            v-for="dict in dict.type.chuku_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="订单类型" prop="orderType">
        <el-select v-model="queryParams.orderType" placeholder="请选择订单类型" clearable>
          <el-option
            v-for="dict in dict.type.order_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="销售订单编号" prop="orderDanhao">
        <el-input
          v-model="queryParams.orderDanhao"
          placeholder="请输入销售订单编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="合同编号" prop="contractCode">
        <el-input
          v-model="queryParams.contractCode"
          placeholder="请输入合同编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!-- <el-form-item label="订单数量" prop="contractNum">
         <el-input
           v-model="queryParams.contractNum"
           placeholder="请输入订单数量"
           clearable
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
       <el-form-item label="计划出库数量" prop="jhckNum">
         <el-input
           v-model="queryParams.jhckNum"
           placeholder="请输入计划出库数量"
           clearable
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
       <el-form-item label="实际出库数量" prop="ckNum">
         <el-input
           v-model="queryParams.ckNum"
           placeholder="请输入实际出库数量"
           clearable
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>-->
      <!--   <el-form-item label="出库日期" prop="chukuDate">
           <el-date-picker clearable
             v-model="queryParams.chukuDate"
             type="date"
             value-format="yyyy-MM-dd"
             placeholder="请选择出库日期">
           </el-date-picker>
         </el-form-item>-->
      <el-form-item label="物料名称" prop="itemName">
        <el-input
          v-model="queryParams.itemName"
          placeholder="请输入物料名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料编码" prop="itemId">
        <el-input
          v-model="queryParams.itemId"
          placeholder="请输入物料编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="规格型号" prop="spec">
        <el-input
          v-model="queryParams.spec"
          placeholder="请输入规格型号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料单位" prop="unit">
        <el-input
          v-model="queryParams.unit"
          placeholder="请输入物料单位"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="批次" prop="lot">
        <el-input
          v-model="queryParams.lot"
          placeholder="请输入批次"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!--   <el-form-item label="供应商" prop="supplyId">
           <el-input
             v-model="queryParams.supplyId"
             placeholder="请输入供应商"
             clearable
             @keyup.enter.native="handleQuery"
           />
         </el-form-item>
         <el-form-item label="供应商名称" prop="supplyName">
           <el-input
             v-model="queryParams.supplyName"
             placeholder="请输入供应商名称"
             clearable
             @keyup.enter.native="handleQuery"
           />
         </el-form-item>-->
      <!-- <el-form-item label="仓库编号" prop="stockId">
         <el-input
           v-model="queryParams.stockId"
           placeholder="请输入仓库编号"
           clearable
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
       <el-form-item label="仓库名称" prop="stockName">
         <el-input
           v-model="queryParams.stockName"
           placeholder="请输入仓库名称"
           clearable
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
       <el-form-item label="库区编码" prop="kuquCode">
         <el-input
           v-model="queryParams.kuquCode"
           placeholder="请输入库区编码"
           clearable
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
       <el-form-item label="库区名称" prop="kuquName">
         <el-input
           v-model="queryParams.kuquName"
           placeholder="请输入库区名称"
           clearable
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>-->
      <el-form-item label="库位编码" prop="kuweiCode">
        <el-input
          v-model="queryParams.kuweiCode"
          placeholder="请输入库位编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!-- <el-form-item label="物料编码" prop="itemCode">
         <el-input
           v-model="queryParams.itemCode"
           placeholder="请输入物料编码"
           clearable
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>-->
      <!--  <el-form-item label="价格" prop="price">
          <el-input
            v-model="queryParams.price"
            placeholder="请输入价格"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="总价" prop="totalPrice">
          <el-input
            v-model="queryParams.totalPrice"
            placeholder="请输入总价"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="单价" prop="unitPrice">
          <el-input
            v-model="queryParams.unitPrice"
            placeholder="请输入单价"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>-->
      <!--   <el-form-item label="物料类型id" prop="classId">
           <el-input
             v-model="queryParams.classId"
             placeholder="请输入物料类型id"
             clearable
             @keyup.enter.native="handleQuery"
           />
         </el-form-item>-->
      <el-form-item label="物料类型" prop="className">
        <el-input
          v-model="queryParams.className"
          placeholder="请输入物料类型"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!-- <el-form-item label="托管标识" prop="isTuoguan">
         <el-input
           v-model="queryParams.isTuoguan"
           placeholder="请输入托管标识"
           clearable
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
       <el-form-item label="质量状态" prop="qualityState">
         <el-input
           v-model="queryParams.qualityState"
           placeholder="请输入质量状态"
           clearable
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>-->
      <!-- <el-form-item label="制造商编码" prop="makerCode">
         <el-input
           v-model="queryParams.makerCode"
           placeholder="请输入制造商编码"
           clearable
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
       <el-form-item label="制造商名称" prop="makerName">
         <el-input
           v-model="queryParams.makerName"
           placeholder="请输入制造商名称"
           clearable
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
       <el-form-item label="尺寸" prop="size">
         <el-input
           v-model="queryParams.size"
           placeholder="请输入尺寸"
           clearable
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
       <el-form-item label="单重" prop="singleWeight">
         <el-input
           v-model="queryParams.singleWeight"
           placeholder="请输入单重"
           clearable
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
       <el-form-item label="总重" prop="totalWeight">
         <el-input
           v-model="queryParams.totalWeight"
           placeholder="请输入总重"
           clearable
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
       <el-form-item label="使用状态" prop="useState">
         <el-input
           v-model="queryParams.useState"
           placeholder="请输入使用状态"
           clearable
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
       <el-form-item label="颜色" prop="color">
         <el-input
           v-model="queryParams.color"
           placeholder="请输入颜色"
           clearable
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
       <el-form-item label="花纹" prop="figure">
         <el-input
           v-model="queryParams.figure"
           placeholder="请输入花纹"
           clearable
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
       <el-form-item label="材质" prop="caizhi">
         <el-input
           v-model="queryParams.caizhi"
           placeholder="请输入材质"
           clearable
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
       <el-form-item label="条形码" prop="txm">
         <el-input
           v-model="queryParams.txm"
           placeholder="请输入条形码"
           clearable
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
       <el-form-item label="托盘码" prop="tpm">
         <el-input
           v-model="queryParams.tpm"
           placeholder="请输入托盘码"
           clearable
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
       <el-form-item label="配送条形码" prop="pstxm">
         <el-input
           v-model="queryParams.pstxm"
           placeholder="请输入配送条形码"
           clearable
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
       <el-form-item label="配送时间" prop="psTime">
         <el-date-picker clearable
           v-model="queryParams.psTime"
           type="date"
           value-format="yyyy-MM-dd"
           placeholder="请选择配送时间">
         </el-date-picker>
       </el-form-item>
       <el-form-item label="组别" prop="zubie">
         <el-input
           v-model="queryParams.zubie"
           placeholder="请输入组别"
           clearable
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
       <el-form-item label="拣货人" prop="pickingName">
         <el-input
           v-model="queryParams.pickingName"
           placeholder="请输入拣货人"
           clearable
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
       <el-form-item label="拣货工段位" prop="pickingSegment">
         <el-input
           v-model="queryParams.pickingSegment"
           placeholder="请输入拣货工段位"
           clearable
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
       <el-form-item label="拣货时间" prop="pickingTime">
         <el-date-picker clearable
           v-model="queryParams.pickingTime"
           type="date"
           value-format="yyyy-MM-dd"
           placeholder="请选择拣货时间">
         </el-date-picker>
       </el-form-item>
       <el-form-item label="条码打印次数" prop="txmPrintNum">
         <el-input
           v-model="queryParams.txmPrintNum"
           placeholder="请输入条码打印次数"
           clearable
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
       <el-form-item label="出库单打印次数" prop="ckPrintNum">
         <el-input
           v-model="queryParams.ckPrintNum"
           placeholder="请输入出库单打印次数"
           clearable
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
       <el-form-item label="器具号" prop="utensilNo">
         <el-input
           v-model="queryParams.utensilNo"
           placeholder="请输入器具号"
           clearable
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
       <el-form-item label="SAP凭证" prop="sapProof">
         <el-input
           v-model="queryParams.sapProof"
           placeholder="请输入SAP凭证"
           clearable
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
       <el-form-item label="状态" prop="ckState">
         <el-input
           v-model="queryParams.ckState"
           placeholder="请输入状态"
           clearable
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
       <el-form-item label="总装入库回写状态" prop="zzhxState">
         <el-input
           v-model="queryParams.zzhxState"
           placeholder="请输入总装入库回写状态"
           clearable
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
       <el-form-item label="总装入时间" prop="zzrkTime">
         <el-date-picker clearable
           v-model="queryParams.zzrkTime"
           type="date"
           value-format="yyyy-MM-dd"
           placeholder="请选择总装入时间">
         </el-date-picker>
       </el-form-item>
       <el-form-item label="总装入库备注" prop="zzrkRemark">
         <el-input
           v-model="queryParams.zzrkRemark"
           placeholder="请输入总装入库备注"
           clearable
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
       <el-form-item label="总装入库人" prop="zzrkName">
         <el-input
           v-model="queryParams.zzrkName"
           placeholder="请输入总装入库人"
           clearable
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
       <el-form-item label="总装入库数" prop="zzrkNum">
         <el-input
           v-model="queryParams.zzrkNum"
           placeholder="请输入总装入库数"
           clearable
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>-->
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['business:chukuInfo:add']"
        >新增
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['business:chukuInfo:edit']"
        >修改
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['business:chukuInfo:remove']"
        >删除
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['business:chukuInfo:export']"
        >导出
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-s-unfold"
          size="mini"
          :disabled="multiple"
          @click="handleAccount"
          v-hasPermi="['business:chukuInfo:edit']"
        >生成订单成本核算
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-s-unfold"
          size="mini"
          :disabled="multiple"
          @click="handleSummary"
          v-hasPermi="['business:chukuInfo:edit']"
        >订单成本汇总
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="chukuInfoList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column label="公司名称" align="center" prop="factoryName"/>
      <el-table-column label="公司代码" align="center" prop="factoryCode"/>
      <el-table-column label="出库单号" align="center" prop="danhao"/>
      <el-table-column label="出库类型" align="center" prop="chukuType">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.chuku_type" :value="scope.row.chukuType"/>
        </template>
      </el-table-column>
      <el-table-column label="订单类型" align="center" prop="orderType">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.order_type" :value="scope.row.orderType"/>
        </template>
      </el-table-column>
      <el-table-column label="项目订单编号" align="center" prop="orderDanhao" width="120"/>
      <el-table-column label="合同编号" align="center" prop="contractCode"/>
      <el-table-column label="订单数量" align="center" prop="contractNum"/>
      <el-table-column label="计划出库数量" align="center" prop="jhckNum"/>
      <el-table-column label="实际出库数量" align="center" prop="ckNum"/>
      <el-table-column label="出库日期" align="center" prop="chukuDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.chukuDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="物料名称" align="center" prop="itemName"/>
      <el-table-column label="物料号" align="center" prop="itemId"/>
      <el-table-column label="子图号" align="center" prop="itemCode"/>
      <el-table-column label="规格型号" align="center" prop="spec"/>
      <el-table-column label="物料单位" align="center" prop="unit"/>
      <el-table-column label="批次" align="center" prop="lot"/>
      <el-table-column label="供应商名称" align="center" prop="supplyName"/>
      <el-table-column label="仓库编号" align="center" prop="stockId"/>
      <el-table-column label="仓库名称" align="center" prop="stockName"/>
      <el-table-column label="库区编码" align="center" prop="kuquCode"/>
      <el-table-column label="库区名称" align="center" prop="kuquName"/>
      <el-table-column label="库位编码" align="center" prop="kuweiCode"/>
<!--      <el-table-column label="价格" align="center" prop="price"/>-->
      <el-table-column label="单价" align="center" prop="unitPrice"/>
      <el-table-column label="总价" align="center" prop="totalPrice"/>
      <el-table-column label="物料类型" align="center" prop="className"/>
      <el-table-column label="备注" align="center" prop="remark"/>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['business:chukuInfo:edit']"
          >修改
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['business:chukuInfo:remove']"
          >删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改出库单对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
        <el-row :gutter="24">
          <el-col :span="12">
            <el-form-item label="公司名称" prop="factoryName">
              <el-input v-model="form.factoryName" placeholder="请输入公司名称"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="公司代码" prop="factoryCode">
              <el-input v-model="form.factoryCode" placeholder="请输入公司代码"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="出库单号" prop="danhao">
              <el-input v-model="form.danhao" placeholder="请输入出库单号"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="出库类型" prop="chukuType">
              <el-select v-model="form.chukuType" placeholder="请选择出库类型">
                <el-option
                  v-for="dict in dict.type.chuku_type"
                  :key="dict.value"
                  :label="dict.label" :value="parseInt(dict.value)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="项目订单编号" prop="orderDanhao">
              <el-input v-model="form.orderDanhao" placeholder="请输入销售订单编号"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="合同编号" prop="contractCode">
              <el-input v-model="form.contractCode" placeholder="请输入合同编号"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="订单类型" prop="orderType">
              <el-select v-model="form.orderType" placeholder="请选择订单类型">
                <el-option
                  v-for="dict in dict.type.order_type"
                  :key="dict.value"
                  :label="dict.label" :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="订单数量" prop="contractNum">
              <el-input v-model="form.contractNum" placeholder="请输入订单数量"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="计划出库数量" prop="jhckNum">
              <el-input v-model="form.jhckNum" placeholder="请输入计划出库数量"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="实际出库数量" prop="ckNum">
              <el-input v-model="form.ckNum" placeholder="请输入实际出库数量"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="出库日期" prop="chukuDate">
              <el-date-picker clearable
                              v-model="form.chukuDate"
                              type="date"
                              value-format="yyyy-MM-dd"
                              placeholder="请选择出库日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料名称" prop="itemName">
              <el-input v-model="form.itemName" placeholder="请输入物料名称"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料编码" prop="itemId">
              <el-input v-model="form.itemId" placeholder="请输入物料编码"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="规格型号" prop="spec">
              <el-input v-model="form.spec" placeholder="请输入规格型号"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料单位" prop="unit">
              <el-input v-model="form.unit" placeholder="请输入物料单位"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="批次" prop="lot">
              <el-input v-model="form.lot" placeholder="请输入批次"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="供应商" prop="supplyId">
              <el-input v-model="form.supplyId" placeholder="请输入供应商"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="供应商名称" prop="supplyName">
              <el-input v-model="form.supplyName" placeholder="请输入供应商名称"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="仓库编号" prop="stockId">
              <el-input v-model="form.stockId" placeholder="请输入仓库编号"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="仓库名称" prop="stockName">
              <el-input v-model="form.stockName" placeholder="请输入仓库名称"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="库区编码" prop="kuquCode">
              <el-input v-model="form.kuquCode" placeholder="请输入库区编码"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="库区名称" prop="kuquName">
              <el-input v-model="form.kuquName" placeholder="请输入库区名称"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="库位编码" prop="kuweiCode">
              <el-input v-model="form.kuweiCode" placeholder="请输入库位编码"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料编码" prop="itemCode">
              <el-input v-model="form.itemCode" placeholder="请输入物料编码"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="价格" prop="price">
              <el-input v-model="form.price" placeholder="请输入价格"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="总价" prop="totalPrice">
              <el-input v-model="form.totalPrice" placeholder="请输入总价"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="单价" prop="unitPrice">
              <el-input v-model="form.unitPrice" placeholder="请输入单价"/>
            </el-form-item>
          </el-col>
<!--          <el-col :span="12">-->
<!--            <el-form-item label="物料类型id" prop="classId">-->
<!--              <el-input v-model="form.classId" placeholder="请输入物料类型id"/>-->
<!--            </el-form-item>-->
<!--          </el-col>-->
          <el-col :span="12">
            <el-form-item label="物料类型" prop="className">
              <el-input v-model="form.className" placeholder="请输入物料类型"/>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="备注" prop="remark">
              <el-input v-model="form.remark" type="textarea" placeholder="请输入内容"/>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {handleSummary,handleAccount,listChukuInfo, getChukuInfo, delChukuInfo, addChukuInfo, updateChukuInfo} from "@/api/business/chukuInfo";

export default {
  name: "ChukuInfoN",
  dicts: ['order_type', 'chuku_type'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 出库单表格数据
      chukuInfoList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        factoryName: null,
        factoryCode: null,
        danhao: null,
        chukuType: null,
        orderType: null,
        orderDanhao: null,
        contractCode: null,
        contractNum: null,
        jhckNum: null,
        ckNum: null,
        chukuDate: null,
        itemName: null,
        itemId: null,
        spec: null,
        unit: null,
        lot: null,
        supplyId: null,
        supplyName: null,
        stockId: null,
        stockName: null,
        kuquCode: null,
        kuquName: null,
        kuweiCode: null,
        itemCode: null,
        price: null,
        totalPrice: null,
        unitPrice: null,
        classId: null,
        className: null,
        isTuoguan: null,
        qualityState: null,
        makerCode: null,
        makerName: null,
        size: null,
        singleWeight: null,
        totalWeight: null,
        useState: null,
        color: null,
        figure: null,
        caizhi: null,
        txm: null,
        tpm: null,
        pstxm: null,
        psTime: null,
        zubie: null,
        pickingName: null,
        pickingSegment: null,
        pickingTime: null,
        txmPrintNum: null,
        ckPrintNum: null,
        utensilNo: null,
        sapProof: null,
        ckState: null,
        zzhxState: null,
        zzrkTime: null,
        zzrkRemark: null,
        zzrkName: null,
        zzrkNum: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {}
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询出库单列表 */
    getList() {
      this.loading = true;
      listChukuInfo(this.queryParams).then(response => {
        this.chukuInfoList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        factoryName: null,
        factoryCode: null,
        danhao: null,
        chukuType: null,
        orderType: null,
        orderDanhao: null,
        contractCode: null,
        contractNum: null,
        jhckNum: null,
        ckNum: null,
        chukuDate: null,
        itemName: null,
        itemId: null,
        spec: null,
        unit: null,
        lot: null,
        supplyId: null,
        supplyName: null,
        stockId: null,
        stockName: null,
        kuquCode: null,
        kuquName: null,
        kuweiCode: null,
        itemCode: null,
        price: null,
        totalPrice: null,
        unitPrice: null,
        classId: null,
        className: null,
        isTuoguan: null,
        qualityState: null,
        makerCode: null,
        makerName: null,
        size: null,
        singleWeight: null,
        totalWeight: null,
        useState: null,
        color: null,
        figure: null,
        caizhi: null,
        txm: null,
        tpm: null,
        pstxm: null,
        psTime: null,
        zubie: null,
        pickingName: null,
        pickingSegment: null,
        pickingTime: null,
        txmPrintNum: null,
        ckPrintNum: null,
        utensilNo: null,
        sapProof: null,
        ckState: null,
        zzhxState: null,
        zzrkTime: null,
        zzrkRemark: null,
        zzrkName: null,
        zzrkNum: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加出库单";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getChukuInfo(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改出库单";
      });
    },
    handleAccount(row){
      const id = row.id || this.ids
      handleAccount(id).then(response => {
        this.$modal.msgSuccess("核算成功");
      });
    },
    handleSummary(row){
      const id = row.id || this.ids
      handleSummary(id).then(response => {
        this.$modal.msgSuccess("汇总成功");
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateChukuInfo(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addChukuInfo(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除出库单编号为"' + ids + '"的数据项？').then(function () {
        return delChukuInfo(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('business/chukuInfo/export', {
        ...this.queryParams
      }, `chukuInfo_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
